package com.ele.service.impl;

import com.ele.dao.EmployeeDao;
import com.ele.dao.impl.EmployeeDaoImpl;
import com.ele.pojo.Employee;
import com.ele.service.EmployeeService;

import java.sql.SQLException;
import java.util.List;

public class EmployeeServiceImpl implements EmployeeService {
    private EmployeeDao employeeDao = new EmployeeDaoImpl();


    public List<Employee> findAll() {
        try {
            return this.employeeDao.findAll();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Integer updateEmp(Employee employee) {
        try {
            return this.employeeDao.updateEmp(employee);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Integer deleteEmpById(String id) {
        try {
            return this.employeeDao.deleteEmpById(id);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Integer addEmp(Employee employee) {
        try {
            return this.employeeDao.addEmp(employee);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<Employee> findEmps(String account, String nickname, String telephone) {
        try {
            return this.employeeDao.findEmps(account,nickname,telephone);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Employee empLogin(String account, String password) {
        try {
            return this.employeeDao.empLogin(account,password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
